#ifndef CustomersModel_H
#define CustomersModel_H

#include "Customer.h"

#include <QStandardItemModel>

class CustomersModel : public QStandardItemModel
 {
     Q_OBJECT

 public:

    static const uint s_columns;

    enum COLUMN
    {
        CUSTOMER_ID                   = 0,
        CUSTOMER_NAME                 = 1,
        CUSTOMER_ADDRESS              = 2,
        CUSTOMER_PHONE                = 3,
        CUSTOMER_NIF                  = 4,
        CUSTOMER_PRICE_TYPE           = 5
    };

    CustomersModel( const std::vector< ecocity::Customer >& products,
                    QObject *parent = 0 );

    void reset( const std::vector< ecocity::Customer >& customers );

    QVariant headerData( int section, Qt::Orientation orientation, int role ) const;

    Qt::ItemFlags flags ( const QModelIndex & index ) const;

    bool add_new_customer( const ecocity::Customer& customer );

    ecocity::Customer customer( const QModelIndex& index ) const;

    // Load and save customers in file
    void save( const QString& file_name );
    bool load( const QString& file_name );

    int get_biggest_id( );

 };

#endif // CustomersModel_H
